package com.guochaojava.util;

import com.guochaojava.model.enums.CodeMessageEnum;

/**
 * @author guochao
 * @since 1.0.0
 */
public class Result {

    public static class ObjectResult extends Result {
        public Integer status;
        public String msg;
        public Object data;

        public ObjectResult() {

        }

        private ObjectResult(Integer status, String msg) {
            this.status = status;
            this.msg = msg;
        }

        private ObjectResult(Integer status, String msg, Object data) {
            this.status = status;
            this.msg = msg;
            this.data = data;
        }
    }


    public static ObjectResult buildOK() {
        return new ObjectResult(CodeMessageEnum.OK.getCode(), CodeMessageEnum.OK.getMessage());
    }

    public static ObjectResult buildOK(String msg) {
        return new ObjectResult(CodeMessageEnum.OK.getCode(), msg);
    }

    public static ObjectResult buildOK(Object data) {
        return new ObjectResult(CodeMessageEnum.OK.getCode(), CodeMessageEnum.OK.getMessage(), data);
    }

    public static ObjectResult buildOK(Object data, String msg) {
        return new ObjectResult(CodeMessageEnum.OK.getCode(), msg, data);
    }

    public static ObjectResult buildOK(Integer code, Object data, String msg) {
        return new ObjectResult(code, msg, data);
    }

    public static ObjectResult buildError() {
        return new ObjectResult(CodeMessageEnum.ERROR.getCode(), CodeMessageEnum.ERROR.getMessage());
    }

    public static ObjectResult buildError(Integer status, String msg) {
        return new ObjectResult(status, msg);
    }

    public static ObjectResult buildError(String msg) {
        return new ObjectResult(CodeMessageEnum.ERROR.getCode(), msg);
    }



    public static class ListResult extends Result {
        public Integer status;
        public String msg;
        public Integer pages;
        public Long total;
        public Object data;

        public ListResult() {

        }

        private ListResult(Integer status, String msg, Integer pages, Long total, Object data) {
            this.status = status;
            this.msg = msg;
            this.pages = pages;
            this.data = data;
            this.total = total;
        }
    }

    public static ListResult buildOK(Integer pages, Long total, Object data) {
        return new ListResult(CodeMessageEnum.OK.getCode(), CodeMessageEnum.OK.getMessage(), pages, total, data);
    }
}
